﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Group.cs" company="DissingNelleman">
//   All rights reserved.
// </copyright>
// <summary>
//   The group.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Services.Dto
{
    using System;
    using System.Runtime.Serialization;

    /// <summary>
    /// The group.
    /// </summary>
    [DataContract]
    public class Group
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        [DataMember]
        public Guid ID { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public string Name { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="obj">
        /// The group.
        /// </param>
        /// <returns>
        /// The <see cref="Group"/>.
        /// </returns>
        public static Group Convert(Models.Domain.Group obj)
        {
            if (obj != null)
            {
                var dto = new Group { ID = obj.ID, Name = obj.Name };
                return dto;
            }
            
            return null;
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Queries
{
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Results;

    /// <summary>
    /// The group query.
    /// </summary>
    [DataContract]
    public class GroupQuery : IQuery
    {
        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <returns>
        /// The <see cref="IResult"/>.
        /// </returns>
        public override IResult Execute(ISession hsession)
        {
            var actioner = new ProjectMeetingActioner(hsession, null);

            return actioner.QueryAllGroups();
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Results
{
    using System.Collections.Generic;
    using System.Runtime.Serialization;

    using ServiceLibrary.Services.Dto;

    /// <summary>
    /// The group result.
    /// </summary>
    [DataContract]
    public class GroupResult : IResult
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="GroupResult"/> class.
        /// </summary>
        public GroupResult()
        {
            this.List = new List<Group>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the list.
        /// </summary>
        [DataMember]
        public List<Group> List { get; set; }

        /// <summary>
        /// Gets or sets the total row count.
        /// </summary>
        [DataMember]
        public int TotalRowCount { get; set; }

        #endregion
    }
}